<template>
	<view class="searchWrap" :style="{padding}">
		<view class="searchBox" :style="{height}">
			<u--input border="none" :placeholder="placeholder" prefixIcon="search"
				prefixIconStyle="font-size: 40rpx;color: #86909C" @change="$u.debounce(searchChange, 300)"
				v-model.trim="searchVal" @confirm="$u.debounce(search, 300)"
				placeholderStyle="background-color:#F7F8FA;height: 72rpx;font-size:28rpx;">
			</u--input>
		</view>
	</view>
</template>

<script>
	export default {
		name: "cus-search",
		props: {
			padding: {
				type: String,
				default: '0 20rpx'
			},
			height: {
				type: String,
				default: '72rpx'
			},
			placeholder: {
				type: String,
				default: '搜索'
			},
		},
		data() {
			return {
				searchVal: ''
			}
		},
		methods: {
			search() {
				this.$emit('search', this.searchVal)
			},
			searchChange() {
				this.$emit('searchChange', this.searchVal)
			}
		}

	}
</script>

<style lang="scss" scoped>
	.searchWrap {
		background-color: #fff;

		.searchBox {
			margin: auto;
			background-color: #F7F8FA;
			display: flex;
			align-items: center;
			padding: 0 24rpx;
		}
	}
</style>